from loguru import logger
from rest_framework.request import Request
from rest_framework import filters, status
from django_filters.rest_framework import DjangoFilterBackend

from apps.cloudhospital.models import CloudHospital
from apps.cloudhospital.serializers import ReadCloudHospitalSerializer, WriteCloudHospitalSerializer
# from apps.prescription.filters import PrescrptionFilter
from op_drf.response import SuccessResponse
from op_drf.viewsets import CustomModelViewSet
from op_drf.pagination import Pagination

class CloudHospitalView(CustomModelViewSet):
    '''
    云医院CRUD功能
    '''

    queryset = CloudHospital.objects.filter(is_delete=False, is_active=True, status="1")
    serializer_class = ReadCloudHospitalSerializer  # 序列化器
    create_serializer_class = WriteCloudHospitalSerializer
    update_serializer_class = WriteCloudHospitalSerializer
    # 分页
    pagination_class = Pagination
    # 筛选
    filter_backends = (DjangoFilterBackend, filters.SearchFilter, filters.OrderingFilter)
    # filter_class = PrescrptionFilter
    search_fields = ("id",)
    filter_fields = ("id",)
    ordering_fields = ("-id",)
    ordering = ["id"]